Skip to content

Add swinv2 to NormalizedConfigManager mapping - #2462

Open
RudrenduPaul wants to merge 1 commit into
huggingface:mainfrom
RudrenduPaul:fix-swinv2-normalized-config-keyerror
Open

Add swinv2 to NormalizedConfigManager mapping#2462
RudrenduPaul wants to merge 1 commit into
huggingface:mainfrom
RudrenduPaul:fix-swinv2-normalized-config-keyerror

Conversation

@RudrenduPaul

@RudrenduPaul RudrenduPaul commented Jul 17, 2026

Copy link
Copy Markdown

What does this PR do?

Fixes #2140.

NormalizedConfigManager raises a KeyError for the swinv2 model type
because it is missing from the _conf mapping in
optimum/utils/normalized_config.py. This breaks ONNX Runtime
optimization for Swin Transformer V2 models.

This PR adds a single entry mapping "swinv2" to NormalizedVisionConfig,
following the same pattern already used for the sibling "donut-swin"
entry. Swinv2Config exposes image_size and num_channels attributes
(see transformers/models/swinv2/configuration_swinv2.py), which is
exactly what NormalizedVisionConfig expects (IMAGE_SIZE = "image_size",
NUM_CHANNELS = "num_channels"), so no new normalized config class is
needed.

Change

Single-line addition, alphabetically ordered per the file's contribution
convention:

"swinv2": NormalizedVisionConfig,

Before submitting

  • Verified Swinv2Config attributes (image_size, num_channels)
    match NormalizedVisionConfig expectations
  • Ran ruff check on the modified file — all checks passed
  • Change is limited to optimum/utils/normalized_config.py

Closes #2140

Note: Claude Code was used to assist in drafting this fix. All changes were reviewed by the submitter.

Swinv2Config exposes image_size and num_channels like other vision
configs (e.g. donut-swin), so map it to NormalizedVisionConfig to fix
the KeyError raised when using swinv2 with ONNX Runtime optimization.

Fixes huggingface#2140
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KeyError: 'swinv2 model type is not supported yet in NormalizedConfig.

1 participant